d4d0f4bd8227dfc5ffb48dc420ac90c193030467,src/edu/stanford/nlp/wordseg/MaxMatchSegmenter.java,MaxMatchSegmenter,main,#String[]#,290
Before Change
public static void main(String[] args) {
Properties props = StringUtils.argsToProperties(args);
System.err.println(props.toString());
MaxMatchSegmenter seg = new MaxMatchSegmenter();
String lexiconFile = props.getProperty("lexicon");
if(lexiconFile != null) {
seg.addLexicon(lexiconFile);
} else {
System.err.println("Error: no lexicon file!");
System.exit(1);
}
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int lineNb = 0;
for(;;) {
++lineNb;
System.err.println("line: "+lineNb);
try {
String line = br.readLine();
if(line == null)
break;
if(props.getProperty("greedy") != null) {
ArrayList<Word> sentence = seg.greedilySegmentWords(line);
System.out.println(Sentence.listToString(sentence));
} else if(props.getProperty("maxwords") != null) {
seg.buildSegmentationLattice(line);
System.out.println
(Sentence.listToString(seg.segmentWords(MatchHeuristic.MAXWORDS)));
} else {
seg.buildSegmentationLattice(line);
System.out.println(Sentence.listToString(seg.maxMatchSegmentation()));
}
}
catch (IOException e) {
After Change
}
public static void main(String[] args) {
Properties props = StringUtils.argsToProperties(args);
// System.err.println(props.toString());
SeqClassifierFlags flags = new SeqClassifierFlags(props);
MaxMatchSegmenter seg = new MaxMatchSegmenter();
String lexiconFile = props.getProperty("lexicon");
if(lexiconFile != null) {
seg.addLexicon(lexiconFile);
} else {
System.err.println("Error: no lexicon file!");
System.exit(1);
}
Sighan2005DocumentReaderAndWriter sighanRW = new Sighan2005DocumentReaderAndWriter();
sighanRW.init(flags);
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringReader strR = null;
PrintWriter stdoutW = new PrintWriter(System.out);
int lineNb = 0;
for(;;) {
++lineNb;
System.err.println("line: "+lineNb);
try {
String line = br.readLine();
if(line == null)
break;
String outputLine = null;
if(props.getProperty("greedy") != null) {
ArrayList<Word> sentence = seg.greedilySegmentWords(line);
outputLine = Sentence.listToString(sentence);
} else if(props.getProperty("maxwords") != null) {
seg.buildSegmentationLattice(line);
outputLine = Sentence.listToString(seg.segmentWords(MatchHeuristic.MAXWORDS));
} else {
seg.buildSegmentationLattice(line);
outputLine = Sentence.listToString(seg.maxMatchSegmentation());
}
strR = new StringReader(outputLine);
Iterator<List<CoreLabel>> itr = sighanRW.getIterator(strR);
while(itr.hasNext()) {
sighanRW.printAnswers(itr.next(), stdoutW);
}
// System.out.println(outputLine);
}
catch (IOException e) {
break;
}
}
stdoutW.flush();
}
private static void printlnErr(String s) {